#include <bits/stdc++.h>
// 2025/02/09
// tag:
// Author: Zhang Muen
using namespace std;

class State {
public:
    int64_t id, weight, cnt;
    State(int64_t i, int64_t w, int c = 0)
    {
        id = i;
        weight = w;
        cnt = c;
    }
};

struct cmp {
    bool operator()(State& a, State& b)
    {
        return a.weight > b.weight;
    }
};

int64_t n, m, k, dist[10001][21];
bool vis[10001][21];
vector<State> graph[10001];

void Dijkstra(int64_t start)
{
    memset(dist, 0x3f, sizeof(dist));
    priority_queue<State, vector<State>, cmp> pq;
    dist[start][0] = 0;
    pq.push(State(start, 0, 0));
    while (!pq.empty()) {
        State state = pq.top();
        pq.pop();
        int u = state.id, cnt = state.cnt;
        if (vis[state.id][state.cnt])
            continue;
        vis[state.id][state.cnt] = true;
        for (auto neighbor : graph[state.id]) {
            int64_t Dist2 = dist[u][cnt] + neighbor.weight;
            if (cnt < k && dist[neighbor.id][cnt + 1] > dist[u][cnt]) {
                dist[neighbor.id][cnt + 1] = dist[u][cnt];
                pq.push(State(neighbor.id, dist[u][cnt], cnt + 1));
            }
            if (dist[neighbor.id][cnt] > Dist2) {
                dist[neighbor.id][cnt] = Dist2;
                pq.push(State(neighbor.id, Dist2, cnt));
            }
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int s, t;
    cin >> n >> m >> k;
    cin >> s >> t;
    int64_t u, v, w;
    for (int i = 0; i < m; i++) {
        cin >> u >> v >> w;
        graph[u].push_back(State(v, w));
        graph[v].push_back(State(u, w)); // ! 自动提示害人不浅
    }
    Dijkstra(s);
    int64_t ans = LONG_LONG_MAX;
    for (int i = 0; i <= k; i++)
        ans = min(ans, dist[t][i]);
    cout << ans << endl;
    return 0;
}